﻿@using PagedList;
@model PagedList.IPagedList<BanDTBLL.san_pham>


@{
    ViewBag.Title = "Danh sách Sản phẩm";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>Danh sách Sản phẩm</h2>

<p>
    @Html.ActionLink("Thêm Sản Phẩm", "ThemSanPham")
</p>
<table>
    <tr>
        <th>
            Loại Sản phẩm
        </th>
        <th>
            Tên Sản phẩm
        </th>
        <th>
            Đơn giá
        </th>
        <th>
            Mô tả tóm tắt
        </th>
        <th>
            Mô tả chi tiết
        </th>
        <th>
            Trạng thái
        </th>
        <th>
            Hình
        </th>
        <th></th>
    </tr>

@foreach (var item in Model)
{
    <tr>
        <td>
            @item.loai_san_pham.tenLoai
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.ten)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.donGia)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.moTaTomTat)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.moTaChiTiet)
        </td>
        <td>
            @item.trang_thai_sp.tenTrangThai 
        </td>
        <td>
            <img src="@Url.Content("~/Content/Images/sanpham/" + @item.hinh)" style ="width : 100px;" />
        </td>
        <td>
            @Html.ActionLink("Edit", "SuaSanPham", new { id = item.ma }) |
            @Html.ActionLink("Delete", "XoaSanPham", new { id = item.ma })
        </td>
    </tr>
}

</table>
<div style="margin-top: 30px;" >
    Trang @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber)
    / @Model.PageCount :
     
    @if (Model.HasPreviousPage)
    {
        
        @Html.ActionLink("Đầu", "ListSanPham", new { page = 1, sortOrder = ViewBag.CurrentSort, currentFilter = ViewBag.CurrentFilter }, new { style = "border-style: solid; border-width: 1px; border-color: #000; padding: 5px; margin-left: 5px;" })
        @Html.Raw(" ");
        @Html.ActionLink("Trở lại", "ListSanPham", new { page = Model.PageNumber - 1, sortOrder = ViewBag.CurrentSort, currentFilter = ViewBag.CurrentFilter }, new { style = "border-style: solid; border-width: 1px; border-color: #000; padding: 5px; margin-left: 5px;" })
    }
    else
    {
        
        @:Đầu
        @Html.Raw(" ");
        @:Trở lại
    }
     
    @if (Model.HasNextPage)
    {
        @: | 
        @Html.ActionLink("Tiếp theo", "ListSanPham", new { page = Model.PageNumber + 1, sortOrder = ViewBag.CurrentSort, currentFilter = ViewBag.CurrentFilter }, new { style = "border-style: solid; border-width: 1px; border-color: #000; padding: 5px; margin-left: 5px;" })
        @Html.Raw(" ");
        @Html.ActionLink("Cuối", "ListSanPham", new { page = Model.PageCount, sortOrder = ViewBag.CurrentSort, currentFilter = ViewBag.CurrentFilter }, new { style = "border-style: solid; border-width: 1px; border-color: #000; padding: 5px; margin-left: 5px;" })
    }
    else
    {
        @: | 
        @:Tiếp theo
        @Html.Raw(" ")
        @:Cuối
    }
</div>